#!/usr/bin/env python
#-*- coding: utf-8 -*-
#__author__:vincentlc
#time: 16/4/7 : 23:06



class Solution(object):
    def isPowerOfThree(self, n):
        """
        :type n: int
        :rtype: bool
        """
        Max3PowerInt = 1162261467
        MaxInt = 1162261467
        if (n <= 0 or n > Max3PowerInt):
            return False
        else:
            return Max3PowerInt % n == 0